﻿// JScript 文件.

function EqualHeight(id){
    var ph = $("#port-"+id).height();
    var min=450;
    if(ph>min){
        $("#form-attention").height(ph);
    }else{
        $("#form-attention").height(min);
        $("#port-"+i).height(min);
    }
}

$(document).ready(function(){
        //判断用户基本信息是否完整.
     $.post("CheckUserInfo.aspx",function(data){
            if(data=="notIntegrated"){
                alert("用户信息填写不完整，请填写。");
                window.location.href="userinfo.htm";
            }
        });
    //初始化弹出窗口.
 
       


    $('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"否": function() { 
				$(this).dialog("close"); 
			}, 
			"是": function() {
			    var name =$("#strvalue").val();
			    var itemno=$("#itemnovalue").val();
			    $.getJSON("CopyItemByName.aspx?name="+escape(name)+"&no="+escape(itemno)+"&format=json&jsoncallback=?",
                    function(data){
                      //赋值.
                      $("input[name='ItemTypeName']").val([data.itemtype]);
                      $("#errorItemType").parent().removeClass();
                      $("#errorItemType").html("").removeClass();
                      $('#tbItemOwner').val(data.itemowner);
                      $("input[name='NoCategory']").val([data.nocategory]);
                      $('#ItemNo').val(data.itemno);
                      $('#tbItemName').val(data.itemname);
                      $("#ItemArea").val(data.area);
                      $("#ItemIndustry").val(data.industry);
                      $("#Address").val(data.address);
                      $("#BuildSize").val(data.buildsize);
                      $('#buildsize').find('label').hide();
                      $("input[name='MoneyType']").val(data.moneytype.split(","));
                      $("#TotalMoney").val(data.totalmoney);
                      $("#CentralMoney").val(data.centralmoney);
                      $("#CentralMoney_1").val(data.centralmoney_1);
                      $("#CentralMoney_2").val(data.centralmoney_2);
                      $("#CentralMoney_3").val(data.centralmoney_3);
                      $("#CentralMoney_4").val(data.centralmoney_4);
                      $("#Intro").val(data.intro);
                      var itemtype=$("input[name='ItemTypeName']:checked").val();
                    if(itemtype=="2"){
                        $("#CentralMoney").parent().addClass("centralmoney_port");
                        $(".centralmoney_port").hide();
                        $("#CentralMoney").val("");
                        $("#CentralMoney_1").val("");
                        $("#CentralMoney_2").val("");
                        $("#CentralMoney_3").val("");
                        $("#CentralMoney_4").val("");
                        $("input[name='MoneyType']").val([]);
            	        
                    }else{
                        $("#CentralMoney").parent().addClass("centralmoney_port");
    	                $(".centralmoney_port").show();
                    }
                      
                });
                $(this).dialog("close"); 
			} 
		}
	});
	
	//给input添加样式.
	$(":text").addClass("txt-box");
	
	//设置隐藏显示效果
	$("input[name='ItemTypeName']").click(function(){
	    var itemtype=$("input[name='ItemTypeName']:checked").val();
	    if(itemtype=="2"){
	        $("#CentralMoney").parent().addClass("centralmoney_port");
	        $(".centralmoney_port").hide();
	        $("#CentralMoney").val("");
	        $("#CentralMoney_1").val("");
	        $("#CentralMoney_2").val("");
	        $("#CentralMoney_3").val("");
	        $("#CentralMoney_4").val("");
	        $("input[name='MoneyType']").val([]);
	        
	    }else{
	        $("#CentralMoney").parent().addClass("centralmoney_port");
	    	$(".centralmoney_port").show();
	    }
	});
	
	$("input[name='TenderMode']").click(function(){
	    var tendermode=$("input[name='TenderMode']:checked").val();
	    if(tendermode=="2"){
	        
	        $("#publish_port").show();
	    }else{
	        //清空数据.
	        $("#PublishTime").val("");
	        $("#PublishMedia").val("");
	        $("#publish_port").hide();
	    }
	
	});
	
	//初始化建设规模.

	var $buildsize = $('#buildsize').addClass('overlabel');
	var $searchInput = $buildsize.find('textarea');
    var $searchLabel = $buildsize.find('label');
    $searchInput.focus(function() {
        $searchLabel.hide();
    }).blur(function() {
        if (this.value == '') {
            $searchLabel.show();
            $('#buildsize').addClass('overlabel');
        }else{
            if(this.value.length >1000){
                $("#errorBuildSize").html("<span class='errormessage'>对不起，最多只能输入1000字。</span>");
                $("#errorBuildSize").parent().addClass("ui-state-error ui-corner-all"); 
            }else{
                $("#errorBuildSize").html("");
                $("#errorBuildSize").parent().removeClass(); 
                $('#buildsize').addClass('overlabel')
            }
        }
    });
    
    $searchLabel.click(function() {
        $searchInput.trigger('focus');
    });
     EqualHeight("0");
    //项目名称.
    $("#tbItemName").focus(function(){
            //如果没有选择项目类型.
            var itemtype = $('input[@name="ItemTypeName"]:checked').val();
            if(!itemtype)
            {
                $("#errorItemType").html("<span class='errormessage'>您还没有选择项目类型！</span>");
                $("#errorItemType").parent().addClass("ui-state-error1");
            }else{
                $("#errorItemType").html("");
                $("#errorItemType").parent().removeClass();
            }
        }).blur(function(){
            //如果未填写 提示需要填写.

            var name = $("#tbItemName").val();
            if(name==""){
                $("#errorItemName").html("<span class='errormessage'>您还没有填写投资项目名称！</span>");
                $("#errorItemName").parent().addClass("ui-state-error1");
            }else{
                $("#errorItemName").html("");
                $("#tbItemName").parent().removeClass();
            }
            
        });
    //批文号.
     $("#ItemNo").focus(function(){
        var valradio = $('input[@name="NoCategory"]:checked').val();
        if(!valradio)
        {
            $("#errorItemNo").html("<span class='errormessage'>您需要选择一种批文号类型</span>");
            $("#errorItemNo").parent().addClass("ui-state-error1");
        }
        else
        {
            $("#errorItemNo").html("");
            $("#errorItemNo").parent().removeClass();
        }
    });
//    $("#ItemNo").blur(function(){
//        var valradio = $('input[@name="NoCategory"]:checked').val();
//        if(!valradio)
//        {
//            $("#errorItemNo").html("<span class='errormessage'>您需要选择一种批文号类型</span>");
//            $("#errorItemNo").parent().addClass("ui-state-error1");
//        }
//        else
//        {
//            $("#errorItemNo").html("");
//            $("#errorItemNo").parent().removeClass();
//        }
//    });
    //给项目名称添加autocomplete功能.
    
    $("#tbItemName")
    .autocomplete("GetInvestByKeyword.aspx")
    .result(function(){
        var item = $('#tbItemName');
        if(item.val()!='共有0条结果'){
            var html="已经有一条名称为：<span style='color:red;'>" + item.val() + "</span>的项目存在，你是否想复制一些曾经填过的信息，再进行修改。<br>";
            $('#dialog > p').html(html);
            $("#strvalue").val(item.val());
            $('#dialog').dialog('open');
		    return false;
        }
     });
     $("#ItemNo")
    .autocomplete("GetInvestByItemNo.aspx")
    .result(function(){
        var item = $('#ItemNo');
        if(item.val()!='共有0条结果'){
            var html="已经有一条编号为：" + item.val() + "的项目存在，你是否想复制一些曾经填过的信息，再进行修改。<br>";
            $('#dialog > p').html(html);
            $("#itemnovalue").val(item.val());
            $('#dialog').dialog('open');
		    return false;
        }
     });
     
     //计算节资率




     $("#CommissionMoney").blur(function(){
        var commission = $("#CommissionMoney").val();
        var tenderaccepted = $("#TenderAcceptedMoney").val();
        var present = SavePersent(commission,tenderaccepted);
        
        $("#SavePresent").val(present);
     });
     
     $("#TenderAcceptedMoney").blur(function(){
        var commission = $("#CommissionMoney").val();
        var tenderaccepted = $("#TenderAcceptedMoney").val();
        var present = SavePersent(commission,tenderaccepted);
        
        $("#SavePresent").val(present);
     });
     
     //检测钱数是否正确.

     $(".floatmoney").blur(function(){
        var value = $(this).val();
        if(!IsFloatNum(value)){
            $(this).parent().addClass("ui-state-error ui-corner-all");
            $(this).next().html("<br>格式不正确，请检查。");
        }else{
            $(this).next().html("");
            $(this).parent().removeClass();
        }

     });
     $(".intnumber").blur(function(){
        var value = $(this).val();
        if(!IsIntNum(value)){
            $(this).parent().addClass("ui-state-error ui-corner-all");
            $(this).next().html("<br>格式不正确，请检查。");
        }else{
            $(this).next().html("");
            $(this).parent().removeClass();
        }

     });
     //时间添加选择器.

     $("#CommissionTime").datepicker({
			changeMonth: true,
			changeYear: true
	 });
	 $("#PublishTime").datepicker({
			changeMonth: true,
			changeYear: true
	 });
	 $("#BidopeningTime").datepicker({
			changeMonth: true,
			changeYear: true
	 });
	 $("#SendNoticeTime").datepicker({
			changeMonth: true,
			changeYear: true
	 });
	
	//计算节资率




	

     
     //附件上传.
     $('#fileInput1').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型(jpg;rar;doc;png;gif;pdf;bmp;ppt;xls;html;htm;mht;zip;txt)',
        'multi':false,
        'buttonText':' ',
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-1').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",1,0)' style='margin-left:10px;'>删除</a>");
           $("input[name='filename1']").val(fileObj.name );
           $("input[name='fileurl1']").val(response);
           $('#fileInput1').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-1').html(error);
            $('#fileInput1').fileUploadCancel(queueID);
        }
    });
    
     $('#fileInput2').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型(jpg;rar;doc;png;gif;pdf;bmp;ppt;xls;html;htm;mht;zip;txt)',
        'buttonText':' ',
        'multi':false,
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-2').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",2,0)' style='margin-left:10px;'>删除</a>");
            $("input[name='filename2']").val(fileObj.name );
           $("input[name='fileurl2']").val(response);
           $('#fileInput2').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-2').html(error);
            $('#fileInput2').fileUploadCancel(queueID);
        }
    });
    
     $('#fileInput3').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型',
        'buttonText':' ',
        'multi':false,
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-3').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",3,0)' style='margin-left:10px;'>删除</a>");
            $("input[name='filename3']").val(fileObj.name );
           $("input[name='fileurl3']").val(response);
           $('#fileInput3').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-3').html(error);
            $('#fileInput3').fileUploadCancel(queueID);
        }
    });
     $('#fileInput4').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型(jpg;rar;doc;png;gif;pdf;bmp;ppt;xls;html;htm;mht;zip;txt)',
        'buttonText':' ',
        'multi':false,
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-4').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",4,0)' style='margin-left:10px;'>删除</a>");
            $("input[name='filename4']").val(fileObj.name );
           $("input[name='fileurl4']").val(response);
           $('#fileInput4').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-4').html(error);
            $('#fileInput4').fileUploadCancel(queueID);
        }
    });
    
     $('#fileInput5').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型(jpg;rar;doc;png;gif;pdf;bmp;ppt;xls;html;htm;mht;zip;txt)',
        'buttonText':' ',
        'multi':false,
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-5').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",5,0)' style='margin-left:10px;'>删除</a>");
            $("input[name='filename5']").val(fileObj.name );
           $("input[name='fileurl5']").val(response);
           $('#fileInput5').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-5').html(error);
            $('#fileInput5').fileUploadCancel(queueID);
        }
    });
    
     $('#fileInput6').fileUpload({
        'uploader': 'images/uploader.swf',
        'fileExt':'*.jpg;*.rar;*.doc;*.png;*.gif;*.pdf;*.bmp;*.ppt;*.xls;*.html;*.htm;*.mht;*.zip;*.txt',
        'fileDesc':'允许的文件类型(jpg;rar;doc;png;gif;pdf;bmp;ppt;xls;html;htm;mht;zip;txt)',
        'buttonText':' ',
        'multi':false,
        'sizeLimit':'2000000',
        'script': 'upload.ashx',
        'folder':'/_uploads',
        'cancelImg': 'images/cancel.png',
        'auto':true,
        onComplete:function(event,queueID,fileObj,response,data){
           $('#filedec-6').html("<img src='images/document.gif' alt='document' /> <a href='"+response+"' target='_blank'>"+fileObj.name + "</a><a href='#' onclick='delfile(\""+response+"\",6,0)' style='margin-left:10px;'>删除</a>");
            $("input[name='filename6']").val(fileObj.name );
           $("input[name='fileurl6']").val(response);
           $('#fileInput6').next().hide();
        },
        onError:function(event,queueID,fileObj,errorObj){
            var error = "";
            if(fileObj.size>2000000)
            {
                error +="抱歉,此文件超过了2MB的附件大小上限。";
            }
            if(error =="")
            {
                error = errorObj.type;
            }
            $('#filedec-6').html(error);
            $('#fileInput6').fileUploadCancel(queueID);
        }
    });
     
});
function delfile(fileurl,index,fileinfo_id){
    $.post("DelFile.aspx",{fileurl:fileurl,fileinfo_id:fileinfo_id,index:index}, function(data){
      
      $('#filedec-'+index).html("");
      $('#fileInput'+index).next().show();
      $('#filename'+index).val("");
      $('#fileurl'+index).val("");
      alert(data);
    });
}
//添加项目
function AddItem(){
    //基本信息部分.
    var itemtype = $("input[name='ItemTypeName']:checked").val();
    var itemname = $('#tbItemName').val();
    var itemowner = $('#tbItemOwner').val();
    var nocategory = $("input:[name='NoCategory']:checked").val();
    if(!nocategory){
        nocategory="";
    }
    var itemno = $('#ItemNo').val();
    var area = $('select#ItemArea option:selected').val();
    var industry = $('select#ItemIndustry option:selected').val();
    var address = $("#Address").val();
    var buildsize = $("#BuildSize").val();
    var totalmoney = $("#TotalMoney").val();
    var centralmoney = $("#CentralMoney").val();
    var centralmoney_1 = $("#CentralMoney_1").val(); 
    var centralmoney_2 = $("#CentralMoney_2").val();
    var centralmoney_3 = $("#CentralMoney_3").val();
    var centralmoney_4 = $("#CentralMoney_4").val();
    var moneytype = ""; //复选框.
    $("input[name='MoneyType']:checked").each(function(){ moneytype += $(this).val()+",";});
    var intro = $("#Intro").val();
    
    //招标信息部分.
    var tenderee = $("#Tenderee").val(); 
    var tendertel = $("#TenderTel").val(); 
    var tendername = $("#TenderName").val(); 
    var tenderno = $("#TenderNo").val(); 
    var principal = $("#Principal").val(); 
    var principaltel = $("#PrincipalTel").val(); 
    var tendertype = "";
    $("input[name='TenderType']:checked").each(function(){tendertype+=$(this).val()+",";});
    var commissiontime = $("#CommissionTime").val(); 
    var commissionmoney = $("#CommissionMoney").val(); 
    var tendermode = $("input[name='TenderMode']:checked").val(); 
    if(!tendermode){
        tendermode="";
    }
    var checkuptype = $("input[name='CheckupType']:checked").val(); //单选框.
    if(!checkuptype){
        checkuptype="";
    }
    var publishtime = $("#PublishTime").val(); 
    var publishmedia = $("#PublishMedia").val(); 
    var bidopeningtime = $("#BidopeningTime").val(); 
    var tendereenum = $("#TendereeNum").val(); 
    var tendereerequest = $("#TendereeRequest").val(); 
    var TenderContent =$("#TenderContent").val();  
    var tenderintro = $("#TenderIntro").val(); 
    
    //中标部分.
    var onlinenum = $("#OnlineNum").val(); 
    var tenderacceptedname = $("#TenderAcceptedName").val(); 
    var tenderacceptedlinkman = $("#TenderAcceptedLinkMan").val(); 
    var tenderacceptedmoney = $("#TenderAcceptedMoney").val(); 
    var tenderacceptedphone = $("#TenderAcceptedPhone").val(); 
    var savepresent = $("#SavePresent").val(); 
    var sendnoticetime = $("#SendNoticeTime").val(); 
    var tenderacceptedintro = $("#TenderAcceptedIntro").val(); 
    
    //附件部分.
    var filename_1 = $("#filename1").val();
    var fileurl_1 = $("#fileurl1").val();
    var filename_2 = $("#filename2").val();
    var fileurl_2 = $("#fileurl2").val();
    var filename_3 = $("#filename3").val();
    var fileurl_3 = $("#fileurl3").val();
    var filename_4 = $("#filename4").val();
    var fileurl_4 = $("#fileurl4").val();
    var filename_5 = $("#filename5").val();
    var fileurl_5 = $("#fileurl5").val();
    var filename_6 = $("#filename6").val();
    var fileurl_6 = $("#fileurl6").val();
    var fileintro = $("#FileIntro").val();
    var msg = "";
    
    //验证数据部分.
    
    //不能为空.
    if(!itemtype){
        msg += "<li>您还没有选择项目类型。</li>";
    }
    if(itemname==""){
        msg +="<li>您还没有填写投资项目名称。</li>";
    }
    if(tendername==""){
        msg +="<li>您还没有填写招标项目名称。</li>";
    }
    //不是正确的钱数.

    if(!IsFloatNum(totalmoney)){
        msg +="<li>项目总投资额填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney)){
        msg +="<li>中央投资额填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_1)){
        msg +="<li>中央预算内资金（含国债）填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_2)){
        msg +="<li>专项建设基金填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_3)){
        msg +="<li>国家主权外债资金填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_4)){
        msg +="<li>其他中央财政投资资金填写的格式不对。</li>";
    }
    if(!IsFloatNum(commissionmoney)){
        msg +="<li>委托金额填写的格式不对。</li>";
    }
    if(!IsFloatNum(tenderacceptedmoney)){
        msg +="<li>中标金额填写的格式不对。</li>";
    }
    //不是正确的数字格式--整数.
    
    if(!IsIntNum(tendereenum)){
        msg +="<li>招标单位（数量）填写的格式不对。</li>";
    }
    if(!IsIntNum(onlinenum)){
        msg +="<li>中标单位填写的格式不对。</li>";
    }
    //判断日期类型.
    if(!IsDateNum(commissiontime)){
        msg +="<li>委托时间填写的格式不对。</li>";
    }
    if(!IsDateNum(publishtime)){
        msg +="<li>公告发布时间填写的格式不对。</li>";
    }
    if(!IsDateNum(bidopeningtime)){
        msg +="<li>开标时间填写的格式不对。</li>";
    }
    if(!IsDateNum(sendnoticetime)){
        msg +="<li>发中标通知书时间填写的格式不对。</li>";
    }
    //规则检查.
    if(Number(totalmoney)<Number(centralmoney)){
        msg +="<li>中央投资额不应该比项目总投资额还多。</li>";
    }
    if(!(Number(centralmoney)==Number(centralmoney_1)+Number(centralmoney_2)+Number(centralmoney_3)+Number(centralmoney_4))){
        msg +="<li>中央预算内资金、专项建设基金、国家主权外债资金、其他中央财政投资资金之和应等于中央投资额。</li>";
    }
    if(Number(tendereenum)<Number(onlinenum)){
        msg +="<li>入围单位数量应小于投标单位数量。</li>";
    }
    
    
    var arr1 = new Array();
    if(commissiontime!=""){
        arr1.push(this.FormartToDate(commissiontime));
    }
    if(publishtime!=""){
        arr1.push(this.FormartToDate(publishtime));
    }
    if(bidopeningtime!=""){
        arr1.push(this.FormartToDate(bidopeningtime));
    }
    if(sendnoticetime!=""){
        arr1.push(this.FormartToDate(sendnoticetime));
    }
    
    var arr2 = new Array();
    for(var i=0;i<arr1.length;i++)
    {
        arr2[i]=arr1[i];
    } 
    this.CompareDate(arr2);
    var time_error = 0;
    for(k=0;k<arr1.length;k++)
    {
        if(arr1[k]!=arr2[k])
        {
            time_error++;
            
        }
    } 
    //alert(time_error);
    if(time_error >0){
        msg +="<li>时间出现顺序有错，应按此顺序出现：委托时间、公告发布时间、开标时间、发中标通知书时间。</li>";
    }
    //显示错误信息.
    if(msg!=""){
        msg="<h2>由于以下表单项填写不正确，导致无法保存，请检查：</h2><ol>" + msg +"</ol>";
        $(".msg-list").html(msg);
        $(".error-mess").show("fast");
        $(document).scrollTop(0);
        return false;
    }
    else
    {
        $(".msg-list").html("");
        $(".error-mess").hide(); 
    }
    //保存数据.
    $.post("SaveItem.aspx", { itemtype: itemtype, itemname: itemname,itemowner:itemowner,nocategory:nocategory,itemno:itemno,
                            area:area,industry:industry,address:address,buildsize:buildsize,totalmoney:totalmoney,centralmoney:centralmoney,
                            centralmoney_1:centralmoney_1,centralmoney_2:centralmoney_2,centralmoney_3:centralmoney_3,centralmoney_4:centralmoney_4,moneytype:moneytype,intro:intro,
                            tenderee:tenderee,tendertel:tendertel,tendername:tendername,tenderno:tenderno,principal:principal,principaltel:principaltel,tendertype:tendertype,
                            commissiontime:commissiontime,commissionmoney:commissionmoney,tendermode:tendermode,checkuptype:checkuptype,publishtime:publishtime,publishmedia:publishmedia,
                            bidopeningtime:bidopeningtime,tendereenum:tendereenum,tendereerequest:tendereerequest,TenderContent:TenderContent,tenderintro:tenderintro,
                            onlinenum:onlinenum,tenderacceptedname:tenderacceptedname,tenderacceptedlinkman:tenderacceptedlinkman,tenderacceptedmoney:tenderacceptedmoney,tenderacceptedphone:tenderacceptedphone,
                            savepresent:savepresent,sendnoticetime:sendnoticetime,tenderacceptedintro:tenderacceptedintro,filename1:filename_1,fileurl1:fileurl_1,filename2:filename_2,fileurl2:fileurl_2,
                            filename3:filename_3,fileurl3:fileurl_3,filename4:filename_4,fileurl4:fileurl_4,filename5:filename_5,fileurl5:fileurl_5,filename6:filename_6,fileurl6:fileurl_6,fileintro:fileintro
                             },
       function(data){
        alert('添加项目成功!');
         window.location.href='Item_Edit.aspx?id='+data;
   });
}

var arrOld = new Array();
var arrNew = new Array();

//获取数据以填充到表格
function LoadMyItemData(id){
    for(var i =0;i<59;i++)
    {
        arrOld[i] = new Array();
    }
    
    $.getJSON("GetMyItemDetails.aspx?id="+id+"&format=json&jsoncallback=?",
                    function(data){
                      //alert(data.itemtype);
                      //赋值.
                      $("input[name='ItemTypeName']").val([data.itemtype]); arrOld[0][0] = "itemtype"; arrOld[0][1] = [data.itemtype];
                      $('#tbItemOwner').val(data.itemowner); arrOld[1][0] = "itemowner" ; arrOld[1][1] = data.itemowner;
                      $('#tbItemName').val(data.itemname); arrOld[2][0] = "itemname" ; arrOld[2][1] = data.itemname;
                      $("input[name='NoCategory']").val([data.nocategory]); arrOld[3][0] = "nocategory"; arrOld[3][1] = [data.nocategory];
                      $('#ItemNo').val(data.itemno); arrOld[4][0] = "itemno"; arrOld[4][1] = data.itemno;
                      $("#ItemArea").val(data.area); arrOld[5][0] = "area"; arrOld[5][1]= data.area=="0"?"":data.area;
                      $("#ItemIndustry").val(data.industry); arrOld[6][0] = "industry"; arrOld[6][1] = data.industry=="0"?"":data.industry;
                      $("#Address").val(data.address); arrOld[7][0] = "address" ; arrOld[7][1] = data.address;
                      $("#BuildSize").val(data.buildsize); arrOld[8][0] = "buildsize"; arrOld[8][1] = data.buildsize;
                      $('#buildsize').find('label').hide(); 
                      $("input[name='MoneyType']").val(data.moneytype.split(",")); arrOld[9][0] = "moneytype"; arrOld[9][1] = data.moneytype;
                      $("#TotalMoney").val(data.totalmoney); arrOld[10][0] = "totalmoney"; arrOld[10][1] = data.totalmoney;
                      $("#CentralMoney").val(data.centralmoney); arrOld[11][0] = "centralmoney"; arrOld[11][1] = data.centralmoney;
                      $("#CentralMoney_1").val(data.centralmoney_1); arrOld[12][0] = "centralmoney_1"; arrOld[12][1] = data.centralmoney_1;
                      $("#CentralMoney_2").val(data.centralmoney_2); arrOld[13][0] = "centralmoney_2"; arrOld[13][1] = data.centralmoney_2;
                      $("#CentralMoney_3").val(data.centralmoney_3); arrOld[14][0] = "centralmoney_3"; arrOld[14][1] = data.centralmoney_3;
                      $("#CentralMoney_4").val(data.centralmoney_4); arrOld[15][0] = "centralmoney_4"; arrOld[15][1] = data.centralmoney_4;
                      $("#Intro").val(data.intro); arrOld[16][0] = "intro" ; arrOld[16][1] = data.intro;
                      
                      $("#Tenderee").val(data.tenderee); arrOld[17][0] = "tenderee" ; arrOld[17][1] = data.tenderee;
                      $("#TenderTel").val(data.tendertel); arrOld[18][0] = "tendertel" ; arrOld[18][1] = data.tendertel;
                      $("#TenderName").val(data.tendername); arrOld[19][0] = "tendername" ; arrOld[19][1] = data.tendername;
                      $("#TenderNo").val(data.tenderno); arrOld[20][0] = "tenderno" ; arrOld[20][1] = data.tenderno;
                      $("#Principal").val(data.principal); arrOld[21][0] = "principal" ; arrOld[22][1] = data.principal;
                      $("#PrincipalTel").val(data.principaltel); arrOld[22][0] = "principaltel" ; arrOld[22][1] = data.principaltel;
                      $("input[name='TenderType']").val(data.tendertype.split(",")); arrOld[23][0] = "tendertype" ; arrOld[23][1] = data.tendertype;
                      $("#CommissionTime").val(data.commissiontime); arrOld[24][0] = "commissiontime" ; arrOld[24][1] = data.commissiontime;
                      $("#CommissionMoney").val(data.commissionmoney); arrOld[25][0] = "commissionmoney" ; arrOld[25][1] = data.commissionmoney;
                      
                      $("input[name='TenderMode']").val([data.tendermode]); arrOld[26][0] = "tendermode" ; arrOld[26][1] = data.tendermode=="0"?"":data.tendermode;
                      $("input[name='CheckupType']").val([data.checkuptype]); arrOld[27][0] = "checkuptype" ; arrOld[27][1] = data.checkuptype=="0"?"":data.checkuptype; //单选框.
                      $("#PublishTime").val(data.publishtime); arrOld[28][0] = "publishtime" ; arrOld[28][1] = data.publishtime;
                      $("#PublishMedia").val(data.publishmedia); arrOld[29][0] = "publishmedia" ; arrOld[29][1] = data.publishmedia;
                      $("#BidopeningTime").val(data.bidopeningtime); arrOld[30][0] = "bidopeningtime" ; arrOld[30][1] = data.bidopeningtime;
                      $("#TendereeNum").val(data.tendereenum); arrOld[31][0] = "tendereenum" ; arrOld[31][1] = data.tendereenum;
                      $("#TendereeRequest").val(data.tendereerequest); arrOld[32][0] = "tendereerequest" ; arrOld[32][1] = data.tendereerequest;
                      $("#TenderContent").val(data.tendercontent); arrOld[33][0] = "tendercontent" ; arrOld[33][1] = data.tendercontent;
                      $("#TenderIntro").val(data.tenderintro); arrOld[34][0] = "tenderintro" ; arrOld[34][1] = data.tenderintro;
                      
                      $("#OnlineNum").val(data.onlinenum); arrOld[35][0] = "onlinenum" ; arrOld[35][1] = data.onlinenum;
                      $("#TenderAcceptedName").val(data.tenderacceptedname); arrOld[36][0] = "tenderacceptedname" ; arrOld[36][1] = data.tenderacceptedname;
                      $("#TenderAcceptedLinkMan").val(data.tenderacceptedlinkman); arrOld[37][0] = "tenderacceptedlinkman" ; arrOld[37][1] = data.tenderacceptedlinkman;
                      $("#TenderAcceptedMoney").val(data.tenderacceptedmoney); arrOld[38][0] = "tenderacceptedmoney" ; arrOld[38][1] = data.tenderacceptedmoney;
                      $("#TenderAcceptedPhone").val(data.tenderacceptedphone); arrOld[39][0] = "tenderacceptedphone" ; arrOld[39][1] = data.tenderacceptedphone;
                      $("#SavePresent").val(data.savepresent); arrOld[40][0] = "savepresent" ; arrOld[40][1] = data.savepresent;
                      $("#SendNoticeTime").val(data.sendnoticetime); arrOld[41][0] = "sendnoticetime" ; arrOld[41][1] = data.sendnoticetime;
                      $("#TenderAcceptedIntro").val(data.tenderacceptedintro); arrOld[42][0] = "tenderacceptedintro" ; arrOld[42][1] = data.tenderacceptedintro;
                      
                      $("#filename1").val(data.filename_1); arrOld[43][0] = "filename_1" ; arrOld[43][1] = data.filename_1;
                      $("#fileurl1").val(data.file_1); arrOld[44][0] = "file_1" ; arrOld[44][1] = data.file_1;
                      if(data.file_1!=""){
                        $("#filedec-1").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_1+"'>"+data.filename_1+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_1+"',1,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput1').next().hide();
                      }
                      $("#filename2").val(data.filename_2); arrOld[45][0] = "filename_2" ; arrOld[45][1] = data.filename_2;
                      $("#fileurl2").val(data.file_2); arrOld[46][0] = "file_2" ; arrOld[46][1] = data.file_2;
                      if(data.file_2!=""){
                        $("#filedec-2").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_2+"'>"+data.filename_2+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_2+"',2,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput2').next().hide();
                      }
                      $("#filename3").val(data.filename_3); arrOld[47][0] = "filename_3" ; arrOld[47][1] = data.filename_3;
                      $("#fileurl3").val(data.file_3); arrOld[48][0] = "file_3" ; arrOld[48][1] = data.file_3;
                      if(data.file_3!=""){
                        $("#filedec-3").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_3+"'>"+data.filename_3+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_3+"',3,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput3').next().hide();
                      }
                      $("#filename4").val(data.filename_4); arrOld[49][0] = "filename_4" ; arrOld[49][1] = data.filename_4;
                      $("#fileurl4").val(data.file_4); arrOld[50][0] = "file_4" ; arrOld[50][1] = data.file_4;
                      if(data.file_4!=""){
                        $("#filedec-4").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_4+"'>"+data.filename_4+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_4+"',4,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput4').next().hide();
                      }
                      $("#filename5").val(data.filename_5); arrOld[51][0] = "filename_5" ; arrOld[51][1] = data.filename_5;
                      $("#fileurl5").val(data.file_5); arrOld[52][0] = "file_5" ; arrOld[52][1] = data.file_5;
                      if(data.file_5!=""){
                        $("#filedec-5").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_5+"'>"+data.filename_5+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_5+"',5,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput5').next().hide();
                      }
                       $("#filename6").val(data.filename_6); arrOld[53][0] = "filename_6" ; arrOld[53][1] = data.filename_6;
                      $("#fileurl6").val(data.file_6); arrOld[54][0] = "file_6" ; arrOld[54][1] = data.file_6;
                      if(data.file_6!=""){
                        $("#filedec-6").html("<img alt='document' src='images/document.gif'/><a href='"+data.file_6+"'>"+data.filename_6+"</a><a style='margin-left: 10px;' onclick=\"delfile('"+data.file_6+"',6,"+data.fileinfo_id+")\" href='#'>删除</a>");
                        $('#fileInput6').next().hide();
                      }
                      
                      $("#FileIntro").val(data.fileintro); arrOld[55][0] = "fileintro" ; arrOld[55][1] = data.fileintro;
                      
                      $("#Invest_ID").val(data.invest_id); arrOld[56][0] = "invest_id" ; arrOld[56][1] = data.invest_id;
                      $("#Item_ID").val(data.item_id); arrOld[57][0] = "item_id" ; arrOld[57][1] = data.item_id;
                      $("#FileInfo_ID").val(data.fileinfo_id); arrOld[58][0] = "fileinfo_id" ; arrOld[58][1] = data.fileinfo_id;
    });
}
function UpdateItem(){
    for(var i =0;i<59;i++)
    {
        arrNew[i] = new Array();
    }
    
    //基本信息部分.
    var itemtype = $("input[name='ItemTypeName']:checked").val(); arrNew[0][0] = "itemtype"; arrNew[0][1] = itemtype;
    var itemname = $('#tbItemName').val(); arrNew[2][0] = "itemname" ; arrNew[2][1] = itemname;
    var itemowner = $('#tbItemOwner').val(); arrNew[1][0] = "itemowner" ; arrNew[1][1] = itemowner;
    var nocategory = $("input:[name='NoCategory']:checked").val();
    if(!nocategory){
        nocategory="";
    }
    arrNew[3][0] = "nocategory"; arrNew[3][1] = nocategory
    var itemno = $('#ItemNo').val(); arrNew[4][0] = "itemno"; arrNew[4][1] = itemno;
    var area = $('select#ItemArea option:selected').val(); arrNew[5][0] = "area"; arrNew[5][1]= area;
    var industry = $('select#ItemIndustry option:selected').val(); arrNew[6][0] = "industry"; arrNew[6][1] = industry
    var address = $("#Address").val(); arrNew[7][0] = "address" ; arrNew[7][1] = address;
    var buildsize = $("#BuildSize").val(); arrNew[8][0] = "buildsize"; arrNew[8][1] = buildsize;
    var totalmoney = $("#TotalMoney").val(); arrNew[10][0] = "totalmoney"; arrNew[10][1] = totalmoney;
    var centralmoney = $("#CentralMoney").val(); arrNew[11][0] = "centralmoney"; arrNew[11][1] = centralmoney;
    var centralmoney_1 = $("#CentralMoney_1").val(); arrNew[12][0] = "centralmoney_1"; arrNew[12][1] = centralmoney_1;
    var centralmoney_2 = $("#CentralMoney_2").val(); arrNew[13][0] = "centralmoney_2"; arrNew[13][1] = centralmoney_2;
    var centralmoney_3 = $("#CentralMoney_3").val(); arrNew[14][0] = "centralmoney_3"; arrNew[14][1] = centralmoney_3;
    var centralmoney_4 = $("#CentralMoney_4").val(); arrNew[15][0] = "centralmoney_4"; arrNew[15][1] = centralmoney_4;
    var moneytype = ""; //复选框.
    $("input[name='MoneyType']:checked").each(function(){ moneytype += $(this).val()+",";}); arrNew[9][0] = "moneytype"; arrNew[9][1] = moneytype;
    var intro = $("#Intro").val(); arrNew[16][0] = "fileintro" ; arrNew[16][1] = intro;
    
    //招标信息部分.
    var tenderee = $("#Tenderee").val(); arrNew[17][0] = "tenderee" ; arrNew[17][1] = tenderee;
    var tendertel = $("#TenderTel").val(); arrNew[18][0] = "tendertel" ; arrNew[18][1] = tendertel;
    var tendername = $("#TenderName").val(); arrNew[19][0] = "tendername" ; arrNew[19][1] = tendername;
    var tenderno = $("#TenderNo").val(); arrNew[20][0] = "tenderno" ; arrNew[20][1] = tenderno;
    var principal = $("#Principal").val(); arrNew[21][0] = "principal" ; arrNew[22][1] = principal;
    var principaltel = $("#PrincipalTel").val(); arrNew[22][0] = "principaltel" ; arrNew[22][1] = principaltel;
    var tendertype = "";
    $("input[name='TenderType']:checked").each(function(){tendertype+=$(this).val()+",";}); arrNew[23][0] = "tendertype" ; arrNew[23][1] = tendertype;
    var commissiontime = $("#CommissionTime").val(); arrNew[24][0] = "commissiontime" ; arrNew[24][1] = commissiontime
    var commissionmoney = $("#CommissionMoney").val(); arrNew[25][0] = "commissionmoney" ; arrNew[25][1] = commissionmoney;
    var tendermode = $("input[name='TenderMode']:checked").val(); 
    if(!tendermode){
        tendermode="";
    }
    arrNew[26][0] = "tendermode" ; arrNew[26][1] = tendermode;
    
    var checkuptype = $("input[name='CheckupType']:checked").val(); //单选框.
    if(!checkuptype){
        checkuptype="";
    }
    arrNew[27][0] = "checkuptype" ; arrNew[27][1] = checkuptype;
    
    var publishtime = $("#PublishTime").val(); arrNew[28][0] = "publishtime" ; arrNew[28][1] = publishtime;
    var publishmedia = $("#PublishMedia").val(); arrNew[29][0] = "publishmedia" ; arrNew[29][1] = publishmedia;
    var bidopeningtime = $("#BidopeningTime").val(); arrNew[30][0] = "bidopeningtime" ; arrNew[30][1] = bidopeningtime;
    var tendereenum = $("#TendereeNum").val(); arrNew[31][0] = "tendereenum" ; arrNew[31][1] = tendereenum;
    var tendereerequest = $("#TendereeRequest").val(); arrNew[32][0] = "tendereerequest" ; arrNew[32][1] = tendereerequest;
    var TenderContent =$("#TenderContent").val(); arrNew[33][0] = "tendercontent" ; arrNew[33][1] = TenderContent;
    var tenderintro = $("#TenderIntro").val(); arrNew[34][0] = "tenderintro" ; arrNew[34][1] = tenderintro;
    
    //中标部分.
    var onlinenum = $("#OnlineNum").val(); arrNew[35][0] = "onlinenum" ; arrNew[35][1] = onlinenum;
    var tenderacceptedname = $("#TenderAcceptedName").val(); arrNew[36][0] = "tenderacceptedname" ; arrNew[36][1] = tenderacceptedname;
    var tenderacceptedlinkman = $("#TenderAcceptedLinkMan").val(); arrNew[37][0] = "tenderacceptedlinkman" ; arrNew[37][1] = tenderacceptedlinkman;
    var tenderacceptedmoney = $("#TenderAcceptedMoney").val(); arrNew[38][0] = "tenderacceptedmoney" ; arrNew[38][1] = tenderacceptedmoney;
    var tenderacceptedphone = $("#TenderAcceptedPhone").val(); arrNew[39][0] = "tenderacceptedphone" ; arrNew[39][1] = tenderacceptedphone;
    var savepresent = $("#SavePresent").val(); arrNew[40][0] = "savepresent" ; arrNew[40][1] = savepresent;
    var sendnoticetime = $("#SendNoticeTime").val(); arrNew[41][0] = "sendnoticetime" ; arrNew[41][1] = sendnoticetime;
    var tenderacceptedintro = $("#TenderAcceptedIntro").val(); arrNew[42][0] = "tenderacceptedintro" ; arrNew[42][1] = tenderacceptedintro;
    
    //附件部分.
    var filename_1 = $("#filename1").val(); arrNew[43][0] = "filename_1" ; arrNew[43][1] = filename_1;
    var fileurl_1 = $("#fileurl1").val(); arrNew[44][0] = "file_1" ; arrNew[44][1] = fileurl_1;
    var filename_2 = $("#filename2").val(); arrNew[45][0] = "filename_2" ; arrNew[45][1] = filename_2;
    var fileurl_2 = $("#fileurl2").val(); arrNew[46][0] = "file_2" ; arrNew[46][1] = fileurl_2;
    var filename_3 = $("#filename3").val(); arrNew[47][0] = "filename_3" ; arrNew[47][1] = filename_3;
    var fileurl_3 = $("#fileurl3").val(); arrNew[48][0] = "file_3" ; arrNew[48][1] = fileurl_3;
    var filename_4 = $("#filename4").val(); arrNew[49][0] = "filename_4" ; arrNew[49][1] = filename_4;
    var fileurl_4 = $("#fileurl4").val(); arrNew[50][0] = "file_4" ; arrNew[50][1] = fileurl_4;
    var filename_5 = $("#filename5").val(); arrNew[51][0] = "filename_5" ; arrNew[51][1] = filename_5;
    var fileurl_5 = $("#fileurl5").val(); arrNew[52][0] = "file_5" ; arrNew[52][1] = fileurl_5;
    var filename_6 = $("#filename6").val(); arrNew[53][0] = "filename_6" ; arrNew[53][1] = filename_6;
    var fileurl_6 = $("#fileurl6").val(); arrNew[54][0] = "file_6" ; arrNew[54][1] = fileurl_6;
    var fileintro = $("#FileIntro").val(); arrNew[55][0] = "fileintro" ; arrNew[55][1] = fileintro;
    
    
    //ID部分
    var invest_id = $("#Invest_ID").val(); arrNew[56][0] = "invest_id" ; arrNew[56][1] = invest_id;
    var fileinfo_id = $("#FileInfo_ID").val(); arrNew[58][0] = "fileinfo_id" ; arrNew[58][1] = fileinfo_id;
    var item_id = $("#Item_ID").val(); arrNew[57][0] = "item_id" ; arrNew[57][1] = item_id;
    
    var msg = "";
    
    //验证数据部分.
    
    //不能为空.
    if(!itemtype){
        msg += "<li>您还没有选择项目类型。</li>";
    }
    if(itemname==""){
        msg +="<li>您还没有填写投资项目名称。</li>";
    }
    if(tendername==""){
        msg +="<li>您还没有填写招标项目名称。</li>";
    }
    //不是正确的钱数.

    if(!IsFloatNum(totalmoney)){
        msg +="<li>项目总投资额填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney)){
        msg +="<li>中央投资额填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_1)){
        msg +="<li>中央预算内资金（含国债）填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_2)){
        msg +="<li>专项建设基金填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_3)){
        msg +="<li>国家主权外债资金填写的格式不对。</li>";
    }
    if(!IsFloatNum(centralmoney_4)){
        msg +="<li>其他中央财政投资资金填写的格式不对。</li>";
    }
    if(!IsFloatNum(commissionmoney)){
        msg +="<li>委托金额填写的格式不对。</li>";
    }
    if(!IsFloatNum(tenderacceptedmoney)){
        msg +="<li>中标金额填写的格式不对。</li>";
    }
    //不是正确的数字格式--整数.
    
    if(!IsIntNum(tendereenum)){
        msg +="<li>招标单位（数量）填写的格式不对。</li>";
    }
    if(!IsIntNum(onlinenum)){
        msg +="<li>中标单位填写的格式不对。</li>";
    }
    //判断日期类型.
    if(!IsDateNum(commissiontime)){
        msg +="<li>委托时间填写的格式不对。</li>";
    }
    if(!IsDateNum(publishtime)){
        msg +="<li>公告发布时间填写的格式不对。</li>";
    }
    if(!IsDateNum(bidopeningtime)){
        msg +="<li>开标时间填写的格式不对。</li>";
    }
    if(!IsDateNum(sendnoticetime)){
        msg +="<li>发中标通知书时间填写的格式不对。</li>";
    }
    //规则检查.
    
    if(Number(totalmoney)<Number(centralmoney)){
        msg +="<li>中央投资额不应该比项目总投资额还多。</li>";
    }

    if(!(Number(centralmoney)==Number(centralmoney_1)+Number(centralmoney_2)+Number(centralmoney_3)+Number(centralmoney_4))){
        msg +="<li>中央预算内资金、专项建设基金、国家主权外债资金、其他中央财政投资资金之和应等于中央投资额。</li>";
    }
    if(Number(tendereenum)<Number(onlinenum)){
        msg +="<li>入围单位数量应小于投标单位数量。</li>";
    }
    
    
    var arr1 = new Array();
    if(commissiontime!=""){
        arr1.push(this.FormartToDate(commissiontime));
    }
    if(publishtime!=""){
        arr1.push(this.FormartToDate(publishtime));
    }
    if(bidopeningtime!=""){
        arr1.push(this.FormartToDate(bidopeningtime));
    }
    if(sendnoticetime!=""){
        arr1.push(this.FormartToDate(sendnoticetime));
    }
    
    
    var arr2 = new Array();
    for(var i=0;i<arr1.length;i++)
    {
        arr2[i]=arr1[i];
    } 
    
    this.CompareDate(arr2);
    var time_error = 0;
    for(k=0;k<arr1.length;k++)
    {
        if(arr1[k]!=arr2[k])
        {
            time_error++;
            
        }
    } 
    if(time_error >0){
        msg +="<li>时间出现顺序有错，应按此顺序出现：委托时间、公告发布时间、开标时间、发中标通知书时间。</li>";
    }
    //显示错误信息.
    if(msg!=""){
        msg="<h2>由于以下表单项填写不正确，导致无法保存，请检查：</h2><ol>" + msg +"</ol>";
        $(".msg-list").html(msg);
        $(".error-mess").show("fast");
        $(document).scrollTop(0);
        return false;
    }
    else
    {
        $(".msg-list").html("");
        $(".error-mess").hide(); 
    }
    //保存数据.
    $.post("UpdateItem.aspx", { invest_id:invest_id,itemtype: itemtype, itemname: itemname,itemowner:itemowner,nocategory:nocategory,itemno:itemno,
                            area:area,industry:industry,address:address,buildsize:buildsize,totalmoney:totalmoney,centralmoney:centralmoney,
                            centralmoney_1:centralmoney_1,centralmoney_2:centralmoney_2,centralmoney_3:centralmoney_3,centralmoney_4:centralmoney_4,moneytype:moneytype,intro:intro,
                            item_id:item_id,tenderee:tenderee,tendertel:tendertel,tendername:tendername,tenderno:tenderno,principal:principal,principaltel:principaltel,tendertype:tendertype,
                            commissiontime:commissiontime,commissionmoney:commissionmoney,tendermode:tendermode,checkuptype:checkuptype,publishtime:publishtime,publishmedia:publishmedia,
                            bidopeningtime:bidopeningtime,tendereenum:tendereenum,tendereerequest:tendereerequest,TenderContent:TenderContent,tenderintro:tenderintro,
                            onlinenum:onlinenum,tenderacceptedname:tenderacceptedname,tenderacceptedlinkman:tenderacceptedlinkman,tenderacceptedmoney:tenderacceptedmoney,tenderacceptedphone:tenderacceptedphone,
                            savepresent:savepresent,sendnoticetime:sendnoticetime,tenderacceptedintro:tenderacceptedintro,
                            fileinfo_id:fileinfo_id,filename1:filename_1,fileurl1:fileurl_1,filename2:filename_2,fileurl2:fileurl_2,
                            filename3:filename_3,fileurl3:fileurl_3,filename4:filename_4,fileurl4:fileurl_4,filename5:filename_5,fileurl5:fileurl_5,filename6:filename_6,fileurl6:fileurl_6,fileintro:fileintro
                             },
       function(data){
         alert(data);
         if(data=="您已成功保存项目！")
         {
            for(var i=0;i<59;i++)
            {
                if(arrOld[i][1]!=arrNew[i][1])
                {
                    $.post("Note_Add.aspx",{columnName:arrOld[i][0],oldValue:arrOld[i][1],newValue:arrNew[i][1],itemno:arrOld[57][1]},function(data){
                        if(data!="true") 
                        {                           
                            alert(data);
                            return;
                        }
                    });
                    arrOld[i][1]=arrNew[i][1];
                }
            }
         }
   });
}